//
//  Rank_PeopleInfoNumberView.m
//  YLProject
//
//  Created by 张伯林 on 2018/2/3.
//  Copyright © 2018年 WY. All rights reserved.
//

#import "Rank_PeopleInfoNumberView.h"

@implementation Rank_PeopleInfoNumberView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}
-(void)createView{
    self.backgroundColor = [UIColor clearColor];
    [self addSubview:self.backView];
    [self addSubview:self.numberLabel];
}
-(void)setNumberText:(NSString *)numberText{
    _numberText = numberText;
    self.numberLabel.text = _numberText;
    [self.numberLabel sizeToFit];
    self.width = self.numberLabel.width +14 * YL_KEY;
    self.height = 16 * YL_KEY;
    self.backView.width = self.width;
    self.backView.height = self.height;
//    self.backView.layer.masksToBounds = YES;
    self.backView.layer.cornerRadius = self.backView.height / 2.0;
    self.numberLabel.center = self.backView.center;
    if (self.block) {
        self.block(CGSizeMake(self.width, self.height));
    }
}
#pragma mark --- 懒加载
-(UIView *)backView{
    if (!_backView) {
        _backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height)];
        _backView.backgroundColor = [UIColor blackColor];
        _backView.alpha = 0.5;
    }
    return _backView;
}
-(UILabel *)numberLabel{
    if (!_numberLabel) {
        _numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.width, self.height)];
        _numberLabel.font = YLFont(13);
        _numberLabel.textColor = [UIColor whiteColor];
        _numberLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _numberLabel;
}
@end
